package com.naiterui.ehp.bs.patient.service;

import java.util.List;

import com.naiterui.ehp.bp.bo.patient.PatientInquirerBO;
import com.naiterui.ehp.bp.domain.Patient;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.patient.vo.inquirer.InquirerInitVO;
import com.naiterui.ehp.bs.patient.vo.inquirer.InquirerParamVO;
import com.naiterui.ehp.bs.patient.vo.inquirer.InquirerRelationVO;
import com.naiterui.ehp.bs.patient.vo.inquirer.InquirerVO;
import com.naiterui.ehp.bs.patient.vo.requestparam.PatientBaseParam;

/**
 * @Description 就诊人管理
 * @Author gongbaoqiang
 * @Date 2020/7/9 3:48 PM
 */
public interface IPatientInquirerService {

    /**
     * 就诊人列表
     * <pre>
     *     1. doctorId为空时，查询患者的全部就诊人
     *     2. 儿科医生时，只能选择18岁以下就诊人
     *     3. 未删除状态
     * </pre>
     *
     * @param patientId
     * @param doctorId
     * @return
     * @throws BusinessException
     */
    List<InquirerVO> list(Long patientId, Long doctorId) throws BusinessException;

    /**
     * 添加就诊人
     * <pre>
     *     1. 所属患者就诊人名称唯一
     *     2. 被添加就诊人已删除时，自动找回
     * </pre>
     *
     * @param paramVO
     * @throws BusinessException
     */
    Long add(InquirerParamVO paramVO) throws BusinessException;

    /**
     * 就诊人详情
     * 
     * @param patientId
     * @param inquirerId
     * @return
     * @throws BusinessException
     */
    InquirerVO detail(Long patientId, Long inquirerId) throws BusinessException;

    /**
     * 删除就诊人
     *
     * @param patientId
     * @param inquirerId
     * @throws BusinessException
     */
    void del(Long patientId, Long inquirerId) throws BusinessException;

    /**
     * 患者与就诊人关系
     *
     * @return
     * @throws BusinessException
     */
    InquirerInitVO relationList(Long patientId) throws BusinessException;

    /**
     * 添加或修改本人为就诊人
     *
     * @param patient
     * @throws BusinessException
     */
    void insertOrUpdateSelf(Patient patient, PatientBaseParam baseParam);

    /**
     * 就诊人列表
     *
     * @param ids
     * @return
     * @throws BusinessException
     */
    List<PatientInquirerBO> findByIds(List<Long> ids) throws BusinessException;

    /**
     * 查询就诊与患者关系
     *
     * @param ids
     * @return
     * @throws BusinessException
     */
    List<InquirerRelationVO> findRelationByPatientId(Long patientId) throws BusinessException;

    /**
     * 按患者和关系查询
     *
     * @param patientId
     * @param relation
     * @return
     * @throws BusinessException
     */
    List<PatientInquirerBO> findByPatientAndRelation(Long patientId, Integer relation) throws BusinessException;

    /**
     * 患者就诊人列表
     *
     * @param patientId
     * @return
     * @throws BusinessException
     */
    List<PatientInquirerBO> findByPatient(Long patientId) throws BusinessException;

    /**
     * 保存或更新就诊人
     *
     * @param paramVO
     * @throws BusinessException
     */
    Long saveOrUpdate(InquirerParamVO paramVO) throws BusinessException;

    /**
     * 获取本人的就诊人
     *
     * @param patientId
     * @return
     */
    Long findMyselfByPatientId(Long patientId);

    void supplementMyselfInfo(Long patientId, String nickName);

    /**
     * 获取默认就诊人
     *
     * @param doctorId 医生ID
     * @param patientId 患者ID
     * @return
     */
    PatientInquirerBO getDefaultInquirerInfoByPatientId(Long doctorId, Long patientId);

    /**
     * 获取就诊人信息
     *
     * @param inquirerId 就诊人ID
     * @return
     */
    PatientInquirerBO getInquirerInfoById(Long inquirerId);

    /**
     * 根据身份证号查询就诊人id列表
     *
     * @param idcard
     * @return
     */
    List<Long> getInquirerIdsByIdcard(String idcard);
}
